package com.tanqing.ddd.domain.command;


import com.tanqing.ddd.domain.aggregate.Parkting;
import com.tanqing.ddd.domain.domain.DomainException;
import com.tanqing.ddd.domain.event.EventQueue;
import com.tanqing.ddd.domain.repository.ParktingRepository;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

@Component
public class NotifyPayCommandHandle {

    @Resource
    private ParktingRepository parktingRepository;
    public boolean handle(EventQueue eventQueue, NotifyPayCommand notifyPayCommand) throws DomainException {

        Parkting parkting = parktingRepository.fundByPlate(notifyPayCommand.getPlate());

        parkting.handle(eventQueue,notifyPayCommand);

        parktingRepository.save(parkting);
        return  true;
    }
}
